{
 "cells": [
  {
   "metadata": {},
   "cell_type": "markdown",
   "source": "## 获取实时行情",
   "id": "cf67a7321f3bb1f9"
  },
  {
   "cell_type": "code",
   "id": "initial_id",
   "metadata": {
    "collapsed": true,
    "ExecuteTime": {
     "end_time": "2024-06-19T02:43:38.474676Z",
     "start_time": "2024-06-19T02:43:37.562702Z"
    }
   },
   "source": [
    "from tqsdk import TqApi, TqSim, TqAuth\n",
    "auth = TqAuth('快期账户', '快期密码')"
   ],
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "在使用天勤量化之前，默认您已经知晓并同意以下免责条款，如果不同意请立即停止使用：https://www.shinnytech.com/blog/disclaimer/\n"
     ]
    }
   ],
   "execution_count": 1
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2024-06-19T02:43:40.994847Z",
     "start_time": "2024-06-19T02:43:38.476915Z"
    }
   },
   "cell_type": "code",
   "source": "api = TqApi(TqSim(), auth=auth)",
   "id": "1e9889a79d1712c6",
   "outputs": [],
   "execution_count": 2
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2024-06-19T02:43:41.019471Z",
     "start_time": "2024-06-19T02:43:40.996711Z"
    }
   },
   "cell_type": "code",
   "source": "q = api.get_quote('SHFE.rb2410')",
   "id": "2882551c574b0eb",
   "outputs": [],
   "execution_count": 3
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2024-06-19T02:43:41.025745Z",
     "start_time": "2024-06-19T02:43:41.021628Z"
    }
   },
   "cell_type": "code",
   "source": "print(q.datetime, q.last_price)",
   "id": "61778b7e63c12fd7",
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "2024-06-19 10:43:40.500000 3639\n"
     ]
    }
   ],
   "execution_count": 4
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2024-06-19T02:43:41.051300Z",
     "start_time": "2024-06-19T02:43:41.027038Z"
    }
   },
   "cell_type": "code",
   "source": "api.close()",
   "id": "d399ddff6ba9fc70",
   "outputs": [],
   "execution_count": 5
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
